package com.wiener.chamilo.engine.services;

import com.wiener.chamilo.engine.beans.Alumno;
import com.wiener.chamilo.webservices.user.WSServiceBindingStub;
import com.wiener.chamilo.webservices.user.WSServiceLocator;

public class UserServiceImpl implements Runnable {

	private Alumno alumno;
	private WSServiceBindingStub binding = null;

	public UserServiceImpl(Alumno alumno) {
		this.alumno = alumno;
	}

	public void run() {
		int value = -3;
		System.out.println("crando alumnos y/o profesores ");
		try {
			binding = (WSServiceBindingStub) new WSServiceLocator()
					.getWSServicePort();
			binding.setTimeout(60000);
			value = binding.WSUserCreateUser(this.alumno.getSecretKey(),
					this.alumno.getFirstname(), this.alumno.getLastname(),
					this.alumno.getStatus(), this.alumno.getLoginname(),
					this.alumno.getPassword(), "",
					this.alumno.getOriginal_user_id_name(),
					this.alumno.getOriginal_user_id_value(),
					this.alumno.getVisibility(), this.alumno.getEmail(),
					this.alumno.getLanguage(), this.alumno.getPhone(),
					this.alumno.getExpiration_date(), null);
			System.out.println("crando alumnos y/o profesores " + value);
		} catch (Exception e) {
			e.printStackTrace();
			/*BufferedWriter output;
			try {
				File errorFile = new File("C://Chamilo//backup//error//error-"+RAM+".txt");
				output = new BufferedWriter(new FileWriter(
						errorFile));
				output.write(this.alumno.getOriginal_user_id_name());
				output.write(this.alumno.getOriginal_user_id_value());
				if (e instanceof AxisFault) {
					output.write(((AxisFault) e).getFaultString());
				} else {
					output.write(e.getMessage());
				}
				output.close();
			} catch (Exception e1) {
				e1.printStackTrace();
			}*/ 
			

		}

	}
}
